<!DOCTYPE html>
<html lang="zh">
<head>
    <meta charset="UTF-8">
<meta name="viewport"
      content="width=device-width, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">

    <meta name="author" content="ZhangPing">





<title>AAPTerr ERROR Unable to open PNG file | ZhangPing&#39;s Blog</title>



    <link rel="icon" href="/favicon.ico">




    <!-- stylesheets list from _config.yml -->
    
    <link rel="stylesheet" href="/css/style.css">
    



    <!-- scripts list from _config.yml -->
    
    <script src="/js/script.js"></script>
    
    <script src="/js/tocbot.min.js"></script>
    



    
    
        
    


<meta name="generator" content="Hexo 4.2.0"></head>
<body>
    <div class="wrapper">
        <header>
    <nav class="navbar">
        <div class="container">
            <div class="navbar-header header-logo"><a href="/">ZhangPing&#39;s Blog</a></div>
            <div class="menu navbar-right">
                
                    <a class="menu-item" href="/archives">Posts</a>
                
                    <a class="menu-item" href="/category">Categories</a>
                
                    <a class="menu-item" href="/tag">Tags</a>
                
                    <a class="menu-item" href="/about">About</a>
                
                <input id="switch_default" type="checkbox" class="switch_default">
                <label for="switch_default" class="toggleBtn"></label>
            </div>
        </div>
    </nav>

    
    <nav class="navbar-mobile" id="nav-mobile">
        <div class="container">
            <div class="navbar-header">
                <div>
                    <a href="/">ZhangPing&#39;s Blog</a><a id="mobile-toggle-theme">·&nbsp;Light</a>
                </div>
                <div class="menu-toggle" onclick="mobileBtn()">&#9776; Menu</div>
            </div>
            <div class="menu" id="mobile-menu">
                
                    <a class="menu-item" href="/archives">Posts</a>
                
                    <a class="menu-item" href="/category">Categories</a>
                
                    <a class="menu-item" href="/tag">Tags</a>
                
                    <a class="menu-item" href="/about">About</a>
                
            </div>
        </div>
    </nav>

</header>
<script>
    var mobileBtn = function f() {
        var toggleMenu = document.getElementsByClassName("menu-toggle")[0];
        var mobileMenu = document.getElementById("mobile-menu");
        if(toggleMenu.classList.contains("active")){
           toggleMenu.classList.remove("active")
            mobileMenu.classList.remove("active")
        }else{
            toggleMenu.classList.add("active")
            mobileMenu.classList.add("active")
        }
    }
</script>
        <div class="main">
            <div class="container">
    
    

    
    <article class="post-wrap">
        <header class="post-header">
            <h1 class="post-title">AAPTerr ERROR Unable to open PNG file</h1>
            
                <div class="post-meta">
                    
                        Author: <a itemprop="author" rel="author" href="/">ZhangPing</a>
                    

                    
                        <span class="post-time">
                        Date: <a href="#">May 7, 2017&nbsp;&nbsp;21:00:00</a>
                        </span>
                    
                    
                        <span class="post-category">
                    Category:
                            
                                <a href="/categories/Android-BUG%E5%A4%84%E7%90%86/">Android-BUG处理</a>
                            
                        </span>
                    
                </div>
            
        </header>

        <div class="post-content">
            <p>标题问题描述并不明确，请参照下面的完整的报错信息</p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br></pre></td><td class="code"><pre><span class="line">AAPT: \\?\C:\Users\平\.android\build-cache\9db38be22f181493e9a5369a6fdf45066821c4c7\output\res\drawable-xhdpi-v4\abc_list_pressed_holo_light.9.png ERROR: Unable to open PNG file</span><br><span class="line">AAPT: \\?\C:\Users\平\.android\build-cache\9db38be22f181493e9a5369a6fdf45066821c4c7\output\res\drawable-hdpi-v4\abc_ic_star_half_black_48dp.png ERROR: Unable to open PNG file</span><br><span class="line">AAPT: \\?\C:\Users\平\.android\build-cache\9db38be22f181493e9a5369a6fdf45066821c4c7\output\res\drawable-mdpi-v4\abc_btn_switch_to_on_mtrl_00012.9.png ERROR: Unable to open PNG file</span><br><span class="line">.</span><br><span class="line">.</span><br><span class="line">.</span><br><span class="line">AAPT err(Facade for 1178074264) : No Delegate set : lost message:\\?\C:\Users\平\.android\build-cache\9db38be22f181493e9a5369a6fdf45066821c4c7\output\res\drawable-mdpi-v4\abc_ic_menu_cut_mtrl_alpha.png ERROR: Unable to open PNG file</span><br><span class="line">AAPT err(Facade for 1178074264) : No Delegate set : lost message:\\?\C:\Users\平\.android\build-cache\9db38be22f181493e9a5369a6fdf45066821c4c7\output\res\drawable-hdpi-v4\notification_bg_normal_pressed.9.png ERROR: Unable to open PNG file</span><br><span class="line">AAPT err(Facade for 1178074264) : No Delegate set : lost message:\\?\C:\Users\平\.android\build-cache\9db38be22f181493e9a5369a6fdf45066821c4c7\output\res\drawable-hdpi-v4\abc_list_pressed_holo_dark.9.png ERROR: Unable to open PNG file</span><br><span class="line">.</span><br><span class="line">.</span><br><span class="line">.</span><br><span class="line">FAILURE: Build completed with 2 failures.</span><br><span class="line"></span><br><span class="line">1: Task failed with an exception.</span><br><span class="line">-----------</span><br><span class="line">* What went wrong:</span><br><span class="line">Execution failed for task &#39;:Volley:mergeDebugAndroidTestResources&#39;.</span><br><span class="line">&gt; Error: java.util.concurrent.ExecutionException: com.android.ide.common.process.ProcessException: </span><br><span class="line"></span><br><span class="line">* Try:</span><br><span class="line">Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.</span><br><span class="line">&#x3D;&#x3D;&#x3D;&#x3D;&#x3D;&#x3D;&#x3D;&#x3D;&#x3D;&#x3D;&#x3D;&#x3D;&#x3D;&#x3D;&#x3D;&#x3D;&#x3D;&#x3D;&#x3D;&#x3D;&#x3D;&#x3D;&#x3D;&#x3D;&#x3D;&#x3D;&#x3D;&#x3D;&#x3D;&#x3D;&#x3D;&#x3D;&#x3D;&#x3D;&#x3D;&#x3D;&#x3D;&#x3D;&#x3D;&#x3D;&#x3D;&#x3D;&#x3D;&#x3D;&#x3D;&#x3D;&#x3D;&#x3D;&#x3D;&#x3D;&#x3D;&#x3D;&#x3D;&#x3D;&#x3D;&#x3D;&#x3D;&#x3D;&#x3D;&#x3D;&#x3D;&#x3D;&#x3D;&#x3D;&#x3D;&#x3D;&#x3D;&#x3D;&#x3D;&#x3D;&#x3D;&#x3D;&#x3D;&#x3D;&#x3D;&#x3D;&#x3D;&#x3D;</span><br><span class="line"></span><br><span class="line">2: Task failed with an exception.</span><br><span class="line">-----------</span><br><span class="line">* What went wrong:</span><br><span class="line">Execution failed for task &#39;:agora:mergeDebugAndroidTestResources&#39;.</span><br><span class="line">&gt; Error: Some file crunching failed, see logs for details</span><br></pre></td></tr></table></figure>

<p>Android Studio 从2.2升级到2.3后，因为svn地址迁移所以重新导入项目，发现报了如上的错误。<br>进入到报错的目录可以发现这些.9的图片都是存在且是正常的.9图片；而且这些图片并不是我倒入进去的，而是V7或引用其他的库编译时自动生成的。<br>试了百度里面很多办法都没能解决，最后在伟大的stackoverflow上面找到了解决方案，在文末附上链接。下面记录下尝试过的办法（stackoverflow也有写）：<br><strong>1.    排查是否有不合格的.9图片。（实际上报错图片不是手动引入的）</strong><br><strong>2.    检查png图片是否合格。（比如由jpg直接改后缀的，而不是导出的）</strong><br><strong>3.    在build.gradle加入设置：</strong></p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br></pre></td><td class="code"><pre><span class="line">aaptOptions &#123;</span><br><span class="line">    cruncherEnabled &#x3D; false</span><br><span class="line">    useNewCruncher&#x3D;false</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>
<p><strong>4.    清除报错路径缓存</strong><br><strong>5.    clean或者rebuild项目</strong></p>
<p>以上的方法都不能解决这个问题，下面说下stackoverflow上的解决办法：</p>
<ol>
<li>According to release notes of Android Studio version 2.3, build cache is enabled by default.</li>
<li>so we should disable this setting. Here is official guide, Android Studio/User Guide/build-cache(link<a href="https://developer.android.com/studio/build/build-cache.html" target="_blank" rel="noopener">https://developer.android.com/studio/build/build-cache.html</a>).</li>
<li>go to gradle.properties file, and disable build cache.<br>// To re-enable the build cache, either delete the following<br>// line or set the property to ‘true’.<br>android.enableBuildCache=false<br>the other way is to modify build cache dir by adding<br>//first line can be skipped because true is the default value by 2.3<br>android.enableBuildCache=true<br>android.buildCacheDir =c:\temp\</li>
</ol>
<p>翻译过来就是：</p>
<ol>
<li>根据Android Studio版本2.3的发行说明，默认情况下启用构建缓存。</li>
<li>所以我们应该禁用这个设置。这是官方指南，Android Studio/User Guide/build-cache（链接<a href="https://developer.android.com/studio/build/build-cache.html）。" target="_blank" rel="noopener">https://developer.android.com/studio/build/build-cache.html）。</a></li>
<li>打开gradle.properties文件，并禁用构建缓存。<br>android.enableBuildCache=false<br>另一种方法是通过添加以下代码来修改构建缓存目录<br>//first line can be skipped because true is the default value by 2.3<br>android.enableBuildCache=true<br>android.buildCacheDir =c:\temp\</li>
</ol>
<p>以上问题解决，可以通过编译。<br>Stackoverflow问题地址：<br><a href="http://stackoverflow.com/questions/42622654/some-file-crunching-failed-mergedebugresources-failed" target="_blank" rel="noopener">http://stackoverflow.com/questions/42622654/some-file-crunching-failed-mergedebugresources-failed</a></p>

        </div>

        
            <section class="post-copyright">
                
                    <p class="copyright-item">
                        <span>Author:</span>
                        <span>ZhangPing</span>
                    </p>
                
                
                    <p class="copyright-item">
                        <span>Permalink:</span>
                        <span><a href="https://zhangpingv5.gitee.io/2017/05/07/AAPTerr/">https://zhangpingv5.gitee.io/2017/05/07/AAPTerr/</a></span>
                    </p>
                
                
                    <p class="copyright-item">
                        <span>License:</span>
                        <span>转载请注明出处</span>
                    </p>
                
                
                     <p class="copyright-item">
                         <span>Slogan:</span>
                         <span>Self-descipline grants me freedom.</span>
                     </p>
                

            </section>
        
        <section class="post-tags">
            <div>
                <span>Tag(s):</span>
                <span class="tag">
                    
                    
                        <a href="/tags/%E7%BC%96%E8%AF%91%E9%94%99%E8%AF%AF/"># 编译错误</a>
                    
                        
                </span>
            </div>
            <div>
                <a href="javascript:window.history.back();">back</a>
                <span>· </span>
                <a href="/">home</a>
            </div>
        </section>
        <section class="post-nav">
            
                <a class="prev" rel="prev" href="/2017/05/09/Android%E8%A7%86%E9%A2%91%E7%BC%93%E5%AD%98%E6%94%AF%E6%8C%81%E5%BA%93/">Android视频缓存实现</a>
            
            
            <a class="next" rel="next" href="/2017/04/25/Android%E6%B7%B7%E6%B7%86%E5%AE%9E%E7%8E%B0/">Android混淆实现</a>
            
        </section>


    </article>
</div>

        </div>
        <footer id="footer" class="footer">
    <div class="copyright">
        <span>© ZhangPing | Powered by <a href="https://hexo.io" target="_blank">Hexo</a> & <a href="https://github.com/Siricee/hexo-theme-Chic" target="_blank">Chic</a></span>
    </div>
</footer>

    </div>
</body>
</html>
